package com.gugee.tiktok.data.common.msg;

import com.gugee.tiktok.data.common.util.ProtostuffUtil;
import lombok.*;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:播主消息
 * User: luolifeng
 * Date: 2020-10-13 14:06
 */

@Data
@Getter
@ToString(callSuper = true)
public class BloggerMessage extends TiktokMessage {


    private long uid;
    private String region="US";

    private String bloggerType;

    /**
     * 任务消息的反序列号
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:03
     */
    public static class MsgDeserializer implements Deserializer<BloggerMessage> {

        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public BloggerMessage deserialize(String topic, byte[] bytes) {
            return ProtostuffUtil.deserializer(bytes, BloggerMessage.class);
        }

        @Override
        public void close() {

        }
    }

    /**
     * Description 类描述
     *
     * @author luolifeng
     * @version 1.0.0
     * Date 2020/10/04
     * Time 15:12
     */
    public static class MsgSerializer implements Serializer<BloggerMessage> {
        @Override
        public void configure(Map map, boolean b) {

        }

        @Override
        public byte[] serialize(String topic, BloggerMessage bloggerMessage) {
            return ProtostuffUtil.serializer(bloggerMessage, BloggerMessage.class);
        }

        @Override
        public void close() {

        }
    }

}

